***********************************************
*********Coding Variables**********************
***********************************************

*Independent Variables

gen age=F_AGECAT_FINAL

gen female=F_SEX_FINAL

gen education=F_EDUCCAT2_FINAL
replace education=. if education>7

gen nonwhite=F_RACETHN_RECRUITMENT
recode nonwhite (1=0)(2 3 4 5 6 7 8=1) (9=.)

gen pid=F_PARTY_FINAL
replace pid=0 if pid==2
replace pid=2 if pid==1
replace pid=1 if pid==3
replace pid=. if pid>3

gen ideology=F_IDEO_FINAL
replace ideology=. if ideology>5
recode ideology (5=6)(4=7)(3=8)(2=9)(1=10)
recode ideology (6=1)(7=2)(8=3)(9=4)(10=5)

gen income=F_INCOME_FINAL
replace income=. if income==99

gen relig_attendance=.
replace relig_attendance=0 if F_ATTEND_FINAL==6
replace relig_attendance=1 if F_ATTEND_FINAL==5
replace relig_attendance=2 if F_ATTEND_FINAL==4
replace relig_attendance=3 if F_ATTEND_FINAL==3
replace relig_attendance=4 if F_ATTEND_FINAL==2
replace relig_attendance=5 if F_ATTEND_FINAL==1


gen rural=0
replace rural=1 if COMTYPE2_W32==3
replace rural=. if COMTYPE2_W32>3

gen suburban=0
replace suburban=1 if COMTYPE2_W32==2
replace suburban=. if COMTYPE2_W32>3

gen urban=0
replace urban=1 if COMTYPE2_W32==1
replace urban=. if COMTYPE2_W32>3

gen urban_rural_dich=.
replace urban_rural_dich=0 if urban==1
replace urban_rural_dich=1 if rural==1
rename urban_rural_dich Rural
///urban=0, rural=1

*Dependent Variables 

*Thinking about how the federal government spends money,
*do you think urban areas get more/less than their fair share

gen fairshare_urban=.
replace fairshare_urban=0 if FEDSHAREA==2
replace fairshare_urban=1 if FEDSHAREA==3
replace fairshare_urban=2 if FEDSHAREA==1
///0=less, 2=more

gen fairshare_urban_dichotomous=.
replace fairshare_urban_dichotomous=0 if FEDSHAREA==2
replace fairshare_urban_dichotomous=1 if FEDSHAREA==1
///0=less, 1=more

*Thinking about how the federal government spends money,
*do you think suburban areas get more/less than their fair share

gen fairshare_suburban=.
replace fairshare_suburban=0 if FEDSHAREB==2
replace fairshare_suburban=1 if FEDSHAREB==3
replace fairshare_suburban=2 if FEDSHAREB==1
///0=less, 2=more

gen fairshare_suburban_dichotomous=.
replace fairshare_suburban_dichotomous=0 if FEDSHAREB==2
replace fairshare_suburban_dichotomous=1 if FEDSHAREB==1
///0=less, 1=more

*Thinking about how the federal government spends money,
*do you think rural areas get more/less than their fair share

gen fairshare_rural=.
replace fairshare_rural=0 if FEDSHAREC==2
replace fairshare_rural=1 if FEDSHAREC==3
replace fairshare_rural=2 if FEDSHAREC==1
///0=less, 2=more

gen fairshare_rural_dichotomous=.
replace fairshare_rural_dichotomous=0 if FEDSHAREC==2
replace fairshare_rural_dichotomous=1 if FEDSHAREC==1
///0=less, 1=more

*Do you think most people who live in urban areas have
*values that are similar to yours?

gen peoplevalues_urban=VALUEURBAN
replace peoplevalues_urban=. if peoplevalues_urban>4
////1=very similar, 4=very different

gen peoplevalues_urban_dich=VALUEURBAN
replace peoplevalues_urban_dich=. if peoplevalues_urban_dich>4
recode peoplevalues_urban_dich (1 2=0)(3 4=1)
////1=similar, 2=different

*Do you think most people who live in suburban areas have
*values that are similar to yours?

gen peoplevalues_suburban=VALUESUBURB
replace peoplevalues_suburban=. if peoplevalues_suburban>4
////1=very similar, 4=very different

gen peoplevalues_suburban_dich=VALUESUBURB
replace peoplevalues_suburban_dich=. if peoplevalues_suburban_dich>4
recode peoplevalues_suburban_dich (1 2=0)(3 4=1)
////1=similar, 2=different

*Do you think most people who live in rural areas have
*values that are similar to yours?

gen peoplevalues_rural=VALUERURAL
replace peoplevalues_rural=. if peoplevalues_rural>4
////1=very similar, 4=very different

gen peoplevalues_rural_dich=VALUERURAL
replace peoplevalues_rural_dich=. if peoplevalues_rural_dich>4
recode peoplevalues_rural_dich (1 2=0)(3 4=1)
////1=similar, 2=different


rename age Age       
rename female Female
rename education Education
rename nonwhite Nonwhite
rename ideology Ideology
rename income Income
rename pid PartyID
rename relig_attendance ReligousAttendance
rename ReligousAttendance ReligiousAttendance

**********************************************************
**************Analysis************************************
**********************************************************

*Figure 1
logit peoplevalues_urban_dich Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
estimates store Urban 

logit peoplevalues_suburban_dich Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
estimates store Suburban 

logit peoplevalues_rural_dich Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
estimates store Rural 

coefplot Urban Suburban Rural, drop(_cons) xline(0) ti("Figure 1. Difference in Values") scheme(sj)

estimates store clear

*Table 1

logit peoplevalues_urban_dich Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
		margins, at(Rural=(0) Age=(2.57) Female=(1.53) Education=(4.12) Nonwhite=(.35) PartyID=(.63) Ideology=(2.71) Income=(5.34) ReligiousAttendance=(1.97)) vsquish
		margins, at(Rural=(1) Age=(2.83) Female=(1.54) Education=(3.57) Nonwhite=(.15) PartyID=(1.14) Ideology=(3.32) Income=(5.49) ReligiousAttendance=(2.26)) vsquish

		margins, at(Education=(1) Rural=(.66) Age=(2.65) Female=(1.61) Nonwhite=(.41) PartyID=(.81) Ideology=(3.29) Income=(3.15) ReligiousAttendance=(2.11)) vsquish
		margins, at(Education=(6) Rural=(.52) Age=(2.90) Female=(1.46) Nonwhite=(.18) PartyID=(.73) Ideology=(2.73) Income=(7.16) ReligiousAttendance=(2.17)) vsquish
		
		margins, at(PartyID=(0) Rural=(.46) Age=(2.78) Female=(1.57) Education=(4.28) Nonwhite=(.32) Ideology=(2.29) Income=(5.79) ReligiousAttendance=(1.82)) vsquish
		margins, at(PartyID=(2) Rural=(.80) Age=(2.93) Female=(1.51) Education=(3.83) Nonwhite=(.10) Ideology=(3.95) Income=(6.05) ReligiousAttendance=(2.84)) vsquish

		margins, at(Ideology=(1) Rural=(.38) Age=(2.62) Female=(1.55) Education=(4.68) Nonwhite=(.22) PartyID=(.24) Income=(5.97) ReligiousAttendance=(1.11)) vsquish
		margins, at(Ideology=(5) Rural=(.75) Age=(2.95) Female=(1.48) Education=(3.74) Nonwhite=(.17) PartyID=(1.65) Income=(5.74) ReligiousAttendance=(3.33)) vsquish

		margins, at(ReligiousAttendance=(0) Rural=(.45) Age=(2.62) Female=(1.45) Education=(4.34) Nonwhite=(.19) Ideology=(2.38) PartyID=(.60) Income=(6.03)) vsquish
		margins, at(ReligiousAttendance=(5) Rural=(.57) Age=(2.98) Female=(1.56) Education=(4.06) Nonwhite=(.34) Ideology=(3.71) PartyID=(1.21) Income=(5.44)) vsquish

logit peoplevalues_suburban_dich Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
		margins, at(Education=(1) Rural=(.66) Age=(2.65) Female=(1.61) Nonwhite=(.41) PartyID=(.81) Ideology=(3.29) Income=(3.15) ReligiousAttendance=(2.11)) vsquish
		margins, at(Education=(6) Rural=(.52) Age=(2.90) Female=(1.46) Nonwhite=(.18) PartyID=(.73) Ideology=(2.73) Income=(7.16) ReligiousAttendance=(2.17)) vsquish

logit peoplevalues_rural_dich Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
		margins, at(Rural=(0) Age=(2.57) Female=(1.53) Education=(4.12) Nonwhite=(.35) PartyID=(.63) Ideology=(2.71) Income=(5.34) ReligiousAttendance=(1.97)) vsquish
		margins, at(Rural=(1) Age=(2.83) Female=(1.54) Education=(3.57) Nonwhite=(.15) PartyID=(1.14) Ideology=(3.32) Income=(5.49) ReligiousAttendance=(2.26)) vsquish

		margins, at(Age=(1) Rural=(.49) Female=(1.51) Education=(3.71) Nonwhite=(.36) PartyID=(.83) Ideology=(2.79) Income=(4.73) ReligiousAttendance=(1.89)) vsquish
		margins, at(Age=(4) Rural=(.66) Female=(1.50) Education=(4.07) Nonwhite=(.11) PartyID=(1.0) Ideology=(3.17) Income=(5.77) ReligiousAttendance=(2.42)) vsquish

		margins, at(Female=(1) Rural=(.62) Age=(2.75) Education=(4.16) Nonwhite=(.23) PartyID=(1.0) Ideology=(3.15) Income=(6.19) ReligiousAttendance=(2.05)) vsquish
		margins, at(Female=(2) Rural=(.63) Age=(2.75) Education=(3.91) Nonwhite=(.23) PartyID=(.9) Ideology=(3.0) Income=(5.48) ReligiousAttendance=(2.25)) vsquish

		margins, at(Nonwhite=(0) Rural=(.69) Age=(2.86) Female=(1.51) Education=(4.11) PartyID=(1.05) Ideology=(3.11) Income=(6.05) ReligiousAttendance=(2.07)) vsquish
		margins, at(Nonwhite=(1) Rural=(.43) Age=(2.39) Female=(1.51) Education=(3.76) PartyID=(.59) Ideology=(2.94) Income=(5.08) ReligiousAttendance=(2.40)) vsquish

		margins, at(Ideology=(1) Rural=(.38) Age=(2.62) Female=(1.55) Education=(4.68) Nonwhite=(.22) PartyID=(.24) Income=(5.97) ReligiousAttendance=(1.11)) vsquish
		margins, at(Ideology=(5) Rural=(.75) Age=(2.95) Female=(1.48) Education=(3.74) Nonwhite=(.17) PartyID=(1.65) Income=(5.74) ReligiousAttendance=(3.33)) vsquish

		margins, at(ReligiousAttendance=(0) Rural=(.45) Age=(2.62) Female=(1.45) Education=(4.34) Nonwhite=(.19) Ideology=(2.38) PartyID=(.60) Income=(6.03)) vsquish
		margins, at(ReligiousAttendance=(5) Rural=(.57) Age=(2.98) Female=(1.56) Education=(4.06) Nonwhite=(.34) Ideology=(3.71) PartyID=(1.21) Income=(5.44)) vsquish

*Figure 2 

logit fairshare_urban_dichotomous Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
estimates store Urban 

logit fairshare_suburban_dichotomous Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
estimates store Suburban 

logit fairshare_rural_dichotomous Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
estimates store Rural 

coefplot Urban Suburban Rural, drop(_cons) xline(0) ti("Figure 2. Difference in Fairness") scheme(sj)

*Table 2

logit fairshare_urban_dichotomous Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
		margins, at(Rural=(0) Age=(2.57) Female=(1.53) Education=(4.12) Nonwhite=(.35) PartyID=(.63) Ideology=(2.71) Income=(5.34) ReligiousAttendance=(1.97)) vsquish
		margins, at(Rural=(1) Age=(2.83) Female=(1.54) Education=(3.57) Nonwhite=(.15) PartyID=(1.14) Ideology=(3.32) Income=(5.49) ReligiousAttendance=(2.26)) vsquish

		margins, at(Age=(1) Rural=(.49) Female=(1.51) Education=(3.71) Nonwhite=(.36) PartyID=(.83) Ideology=(2.79) Income=(4.73) ReligiousAttendance=(1.89)) vsquish
		margins, at(Age=(4) Rural=(.66) Female=(1.50) Education=(4.07) Nonwhite=(.11) PartyID=(1.0) Ideology=(3.17) Income=(5.77) ReligiousAttendance=(2.42)) vsquish

		margins, at(Education=(1) Rural=(.66) Age=(2.65) Female=(1.61) Nonwhite=(.41) PartyID=(.81) Ideology=(3.29) Income=(3.15) ReligiousAttendance=(2.11)) vsquish
		margins, at(Education=(6) Rural=(.52) Age=(2.90) Female=(1.46) Nonwhite=(.18) PartyID=(.73) Ideology=(2.73) Income=(7.16) ReligiousAttendance=(2.17)) vsquish

		margins, at(PartyID=(0) Rural=(.46) Age=(2.78) Female=(1.57) Education=(4.28) Nonwhite=(.32) Ideology=(2.29) Income=(5.79) ReligiousAttendance=(1.82)) vsquish
		margins, at(PartyID=(2) Rural=(.80) Age=(2.93) Female=(1.51) Education=(3.83) Nonwhite=(.10) Ideology=(3.95) Income=(6.05) ReligiousAttendance=(2.84)) vsquish

		margins, at(Ideology=(1) Rural=(.38) Age=(2.62) Female=(1.55) Education=(4.68) Nonwhite=(.22) PartyID=(.24) Income=(5.97) ReligiousAttendance=(1.11)) vsquish
		margins, at(Ideology=(5) Rural=(.75) Age=(2.95) Female=(1.48) Education=(3.74) Nonwhite=(.17) PartyID=(1.65) Income=(5.74) ReligiousAttendance=(3.33)) vsquish
		
		
logit fairshare_suburban_dichotomous Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
		margins, at(Rural=(0) Age=(2.57) Female=(1.53) Education=(4.12) Nonwhite=(.35) PartyID=(.63) Ideology=(2.71) Income=(5.34) ReligiousAttendance=(1.97)) vsquish
		margins, at(Rural=(1) Age=(2.83) Female=(1.54) Education=(3.57) Nonwhite=(.15) PartyID=(1.14) Ideology=(3.32) Income=(5.49) ReligiousAttendance=(2.26)) vsquish

		margins, at(Age=(1) Rural=(.49) Female=(1.51) Education=(3.71) Nonwhite=(.36) PartyID=(.83) Ideology=(2.79) Income=(4.73) ReligiousAttendance=(1.89)) vsquish
		margins, at(Age=(4) Rural=(.66) Female=(1.50) Education=(4.07) Nonwhite=(.11) PartyID=(1.0) Ideology=(3.17) Income=(5.77) ReligiousAttendance=(2.42)) vsquish

logit fairshare_rural_dichotomous Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
		margins, at(Rural=(0) Age=(2.57) Female=(1.53) Education=(4.12) Nonwhite=(.35) PartyID=(.63) Ideology=(2.71) Income=(5.34) ReligiousAttendance=(1.97)) vsquish
		margins, at(Rural=(1) Age=(2.83) Female=(1.54) Education=(3.57) Nonwhite=(.15) PartyID=(1.14) Ideology=(3.32) Income=(5.49) ReligiousAttendance=(2.26)) vsquish

		margins, at(Female=(1) Rural=(.62) Age=(2.75) Education=(4.16) Nonwhite=(.23) PartyID=(1.0) Ideology=(3.15) Income=(6.19) ReligiousAttendance=(2.05)) vsquish
		margins, at(Female=(2) Rural=(.63) Age=(2.75) Education=(3.91) Nonwhite=(.23) PartyID=(.9) Ideology=(3.0) Income=(5.48) ReligiousAttendance=(2.25)) vsquish

		margins, at(Education=(1) Rural=(.66) Age=(2.65) Female=(1.61) Nonwhite=(.41) PartyID=(.81) Ideology=(3.29) Income=(3.15) ReligiousAttendance=(2.11)) vsquish
		margins, at(Education=(6) Rural=(.52) Age=(2.90) Female=(1.46) Nonwhite=(.18) PartyID=(.73) Ideology=(2.73) Income=(7.16) ReligiousAttendance=(2.17)) vsquish

		margins, at(ReligiousAttendance=(0) Rural=(.45) Age=(2.62) Female=(1.45) Education=(4.34) Nonwhite=(.19) Ideology=(2.38) PartyID=(.60) Income=(6.03)) vsquish
		margins, at(ReligiousAttendance=(5) Rural=(.57) Age=(2.98) Female=(1.56) Education=(4.06) Nonwhite=(.34) Ideology=(3.71) PartyID=(1.21) Income=(5.44)) vsquish

*Appendix Table B1

logit peoplevalues_urban_dich Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
logit peoplevalues_suburban_dich Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
logit peoplevalues_rural_dich Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]

*Appendix Table B2

logit fairshare_urban_dichotomous Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
logit fairshare_suburban_dichotomous Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
logit fairshare_rural_dichotomous Rural Age Female Education Nonwhite PartyID Ideology Income ReligiousAttendance [pweight=WEIGHT_W32]
